#!/bin/bash

DEST=`pwd`/build/libuchardet && rm -rf $DEST
SOURCE=`pwd`/uchardet
ANDROID_CMAKE=`pwd`/android-cmake/android.toolchain.cmake

TOOLCHAIN=/home/dev/android/toolchain
export ANDROID_STANDALONE_TOOLCHAIN=$TOOLCHAIN
PLATFORM="armeabi"
cd $SOURCE

PREFIX="$DEST/$PLATFORM" && mkdir -p $PREFIX

cmake -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE \
  -DANDROID_ABI="$PLATFORM" \
  -DENABLE_STATIC=ON \
  -DCMAKE_INSTALL_PREFIX=$PREFIX \

make clean
make -j8 || exit 1
make install || exit 1

cd ..
zip -r libuchardet.zip $DEST
mv libuchardet.zip /data/
